home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Programming / MuManual / Autodocs / fpsp.doc < prev    next >
Text File  |  2000-03-29  |  10KB  |  262 lines

  1. TABLE OF CONTENTS
  2.  
  3. fpsp.resource/--Background--
  4. fpsp.resource/FPSPMonadic
  5. fpsp.resource/FPSPDyadic
  6.  
  7. fpsp.resource/--Background--           fpsp.resource/--Background--
  8.  
  9.     PURPOSE
  10.  
  11.     This resource contains the emulation routines for FPU instructions
  12.     which are non-native for the 68040 or the 68060 processor.
  13.     This resource is - as all resources - not disk based. Instead, it
  14.     is build by the 68040 or 68060.library on startup. The CPU driver
  15.     libraries install the "FPSP" code as part of their initialization
  16.     process, such that every non-impelemented FPU instruction will be
  17.     emulated properly. However, this means that for every such 
  18.     instruction, the CPU has to go thru exception processing, and will
  19.     therefore stop multitasking when emulating a non-implemented in-
  20.     struction. Calling the fpsp routines directly thru the new
  21.     fpsp.resource will prevent this overhead and will gain some speed.
  22.     
  23.     A separate patch - the FastIEEE program - will patch the system
  24.     math libraries to make use of this resource.    
  25.  
  26.     The fpsp.resource is re-entrant, interrupt-callable code. The
  27.     resource offers only two functions which emulate monadic resp.
  28.     dyadic functions of the 68881/68882 FPU on a 68040 FPU.
  29.  
  30.     Currently, only the V40 68040.library builds and provides this
  31.     resource, future versions of the 68060.library might offer this
  32.     as well.
  33.  
  34.     These functions are designed to be stub functions for assembly
  35.     language, they are not designed to be callable from C or any
  36.     other high-level language. Typical applications would call these
  37.     routines indirectly thru a link library which provides all
  38.     requires parameters. Direct calling from within application
  39.     programs is not desired.
  40.  
  41.     Moreover, the FPSP routines *do not* generate FPU exceptions them-
  42.     selves for speed reasons. If this is desired, the calling routine 
  43.     has to check the fpcr and the fpsr FPU registers manually and
  44.     has to generate the exceptions itself.
  45.  
  46. fpsp.resource/FPSPMonadic              fpsp.resource/FPSPMonadic
  47.  
  48.     NAME
  49.     FPSPMonadic     -   emulate a monadic 68881/68882 instruction
  50.  
  51.     SYNOPSIS
  52.     storeflag = FPSPMonadic ( opword, operand );
  53.     d0               d0      fp0
  54.  
  55.     BYTE FPUControl ( UWORD , IEEEExtended );
  56.  
  57.     FUNCTION
  58.     This function emulates the 68881/68882 monadic instruction 
  59.     passed in in register d0, and performs the desired mathematical
  60.     operation on FP0. It returns the result in the FPU register FP0 
  61.     and FP1.
  62.  
  63.     INPUTS
  64.     opword      -   The extension word of a valid 68881/68882 
  65.             instruction. Valid extension words are found in
  66.             the motorola family guide or the 68881/68882
  67.             manual.
  68.             Note that this is actually the SECOND (!) opword
  69.             of the 68881/68882 instruction.
  70.             The bits of the opword have to be specified as
  71.             follows:
  72.  
  73.             Bits 15 and 13 must be cleared. The fpsp.resource
  74.             does not emulate FPU control instructions.
  75.             It emulates all transcendential math instructions,
  76.             and "fint" and "fintrz". Even though these two
  77.             instructions are "native" for the 68060, calling
  78.             the resource with these opwords works correctly.
  79.  
  80.  
  81.             R/M:    Source operand mode,    bit 14.
  82.                 Must be set to zero.
  83.             Source: Source specifier,       bits 12 to 10.
  84.                 Must be set to zero.
  85.             Dest:   Destination specifier,  bits 9 to 7.
  86.                 Must be set to zero.
  87.             Inst:   Instruction field,      bits 5 to 0.
  88.                 Must be filled with the opcode of the
  89.                 desired instruction, see the motorola
  90.                 documents for the list. For the special
  91.                 case of FPSINCOS, the FPC field, bits
  92.                 2 to 0, has to be set to 001 to encode
  93.                 FP1 as secondary result register.
  94.  
  95.     operand     -   A valid IEEE extended precision number as argument
  96.             to the function to be performed.
  97.  
  98.     Secondary inputs are delivered in the FPU registers FPCR and FPSR,
  99.     namely to select the rounding precision and the behaiviour in case
  100.     of invalid arguments or infinite results.
  101.  
  102.     RESULTS
  103.     storeflag   -   This is set to 0 in case the FPSP routine could
  104.             generate a result. THIS DOES NOT MEAN that the
  105.             arguments are valid. In case all exceptions are
  106.             disabled, the storeflag will always be returned as
  107.             zero, but the result might be infinite or a NAN.
  108.  
  109.     Secondary results are delivered in the FPU registers FP0, FP1 and
  110.     FPSR.
  111.  
  112.     FP0 contains the (primary) result of the 68881/68882 instruction
  113.     in case the storeflag is 0. *IT MIGHT WELL BE A NAN OR AN INF*
  114.  
  115.     In case the storeflag is non-zero, FP0 is undefined and the FPSP
  116.     routines indicate that an exception should be generated by the
  117.     caller. This happens only if an exception condition was detected
  118.     and the corresponding exception has been enabled in the FPCR 
  119.     passed in. In all other cases a NAN or a INF will be returned
  120.     and the storeflag will indicate a valid result.
  121.  
  122.     FP1 contains a secondary result, if any. The only case were FP1
  123.     is used is the FSINCOS instruction where the sine is returned in
  124.     FP0 and the cosine in FP1. Otherwise undefined.
  125.  
  126.     FPSR contains the FPU status similar to what a real 68881/68882 
  127.     would have returned. 
  128.  
  129.     NOTES
  130.     This function should not be called directly. It should either be
  131.     called by the system math libraries, or by compiler link libaries.
  132.  
  133.     Note that a non-zero store flag indicates that an exception 
  134.     condition was detected. NOTE THAT THE FPSP CODE DOES NOT CAUSE
  135.     AN EXCEPTION ITSELF. It is the responsibility of the caller to
  136.     check the FPSR, the FPCR and the storeflag to generate this
  137.     exception itself, if desireable. In case the storeflag is non-
  138.     zero, no useful result is returned in FP0 or FP1.
  139.  
  140.     Useful instruction opwords can be found in the motorola 
  141.     documentation, either the MC68K family guide, or in the 68881/
  142.     68882 manual.
  143.  
  144.     This function does not require a6 to be loaded with the FPSP 
  145.     resource base. It is interrupt-callable.
  146.  
  147.     BUGS
  148.  
  149.     SEE ALSO
  150.     libraries/68040.h, FPSPDyadic,
  151.     the Motorola 68881/68882 manual, the MC68K family guide.
  152.  
  153. fpsp.resource/FPSPDyadic               fpsp.resource/FPSPDyadic
  154.  
  155.     NAME
  156.     FPSPDyadic      -   emulate a dyadic 68881/68882 instruction
  157.  
  158.     SYNOPSIS
  159.     storeflag = FPSPMonadic ( opword, operand1, operand2 );
  160.     d0               d0      fp0     fp1
  161.  
  162.     BYTE FPUControl ( UWORD , IEEEExtended , IEEEExtended );
  163.  
  164.     FUNCTION
  165.     This function emulates the 68881/68882 dyadic instruction 
  166.     passed in in register d0, and performs the desired mathematical
  167.     operation on FP0 and FP1. It returns the result in the FPU 
  168.     register FP0.
  169.  
  170.     INPUTS
  171.     opword      -   The extension word of a valid 68881/68882 
  172.             instruction. Valid extension words are found in
  173.             the motorola family guide or the 68881/68882
  174.             manual.
  175.             Note that this is actually the SECOND (!) opword
  176.             of the 68881/68882 instruction.
  177.             The bits of the opword have to be specified as
  178.             follows:
  179.  
  180.             Bits 15 and 13 must be cleared. The fpsp.resource
  181.             does not emulate FPU control instructions.
  182.             It emulates all transcendential math instructions,
  183.             and "fint" and "fintrz". Even though these two
  184.             instructions are "native" for the 68060, calling
  185.             the resource with these opwords works correctly.
  186.  
  187.             R/M:    Source operand mode,    bit 14.
  188.                 Must be set to zero.
  189.             Source: Source specifier,       bits 12 to 10.
  190.                 Must be set to zero.
  191.             Dest:   Destination specifier,  bits 9 to 7.
  192.                 Must be set to zero.
  193.             Inst:   Instruction field,      bits 5 to 0.
  194.                 Must be filled with the opcode of the
  195.                 desired instruction, see the motorola
  196.                 documents for the list. For the special
  197.                 case of FPSINCOS, the FPC field, bits
  198.                 2 to 0, has to be set to 001 to encode
  199.                 FP1 as secondary result register.
  200.  
  201.     operand1    -   A valid IEEE extended precision number as argument
  202.             to the function to be performed. This is the source
  203.             operand of dyadic instructions.
  204.  
  205.     operand2    -   The destination operand of the dyadic 68881/68882
  206.             instructions.
  207.  
  208.     Secondary inputs are delivered in the FPU registers FPCR and FPSR,
  209.     namely to select the rounding precision and the behaiviour in case
  210.     of invalid arguments or infinite results.
  211.  
  212.     RESULTS
  213.     storeflag   -   This is set to 0 in case the FPSP routine could
  214.             generate a result. THIS DOES NOT MEAN that the
  215.             arguments are valid. In case all exceptions are
  216.             disabled, the storeflag will always be returned as
  217.             zero, but the result might be infinite or a NAN.
  218.  
  219.     Secondary results are delivered in the FPU registers FP0, FP1 and
  220.     FPSR.
  221.  
  222.     FP0 contains the (primary) result of the 68881/68882 instruction
  223.     in case the storeflag is 0. *IT MIGHT WELL BE A NAN OR AN INF*
  224.  
  225.     In case the storeflag is non-zero, FP0 is undefined and the FPSP
  226.     routines indicate that an exception should be generated by the
  227.     caller. This happens only if an exception condition was detected
  228.     and the corresponding exception has been enabled in the FPCR 
  229.     passed in. In all other cases a NAN or a INF will be returned
  230.     and the storeflag will indicate a valid result.
  231.  
  232.     FP1 contains a secondary result, if any. As there is currently no
  233.     dyadic opcode with a secondary result, this register should be
  234.     ignored.
  235.  
  236.     FPSR contains the FPU status similar to what a real 68881/68882 
  237.     would have returned. 
  238.  
  239.     NOTES
  240.     This function should not be called directly. It should either be
  241.     called by the system math libraries, or by compiler link libaries.
  242.  
  243.     Note that a non-zero store flag indicates that an exception 
  244.     condition was detected. NOTE THAT THE FPSP CODE DOES NOT CAUSE
  245.     AN EXCEPTION ITSELF. It is the responsibility of the caller to
  246.     check the FPSR, the FPCR and the storeflag to generate this
  247.     exception itself, if desireable. In case the storeflag is non-
  248.     zero, no useful result is returned in FP0 or FP1.
  249.  
  250.     Useful instruction opwords can be found in the motorola 
  251.     documentation, either the MC68K family guide, or in the 68881/
  252.     68882 manual.
  253.  
  254.     This function does not require a6 to be loaded with the FPSP 
  255.     resource base. It is interrupt-callable.
  256.  
  257.     BUGS
  258.  
  259.     SEE ALSO
  260.     libraries/68040.h, FPSPMonadic,
  261.     the Motorola 68881/68882 manual, the MC68K family guide.
  262.